home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / text_eng.zip / GIF_LIB.H < prev    next >
C/C++ Source or Header  |  1995-12-12  |  9KB  |  190 lines

  1. /******************************************************************************
  2. * In order to make life a little bit easier when using the GIF file format,   *
  3. * this library was written, and which does all the dirty work...              *
  4. *                                                                             *
  5. *                                       Written by Gershon Elber,  Jun. 1989  *
  6. *******************************************************************************
  7. * History:                                                                    *
  8. * 14 Jun 89 - Version 1.0 by Gershon Elber.                                   *
  9. *  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). *
  10. ******************************************************************************/
  11.  
  12. #ifndef GIF_LIB_H
  13. #define GIF_LIB_H
  14.  
  15. #define GIF_LIB_VERSION " Version 1.2, "
  16.  
  17. #define GIF_ERROR       0
  18. #define GIF_OK          1
  19.  
  20. #ifndef TRUE
  21. #define TRUE            1
  22. #define FALSE           0
  23. #endif
  24.  
  25. #define GIF_FILE_BUFFER_SIZE 16384  /* Files uses bigger buffers than usual. */
  26.  
  27. typedef short             GifBooleanType;
  28. typedef unsigned char   GifPixelType;
  29. typedef unsigned char * GifRowType;
  30. typedef unsigned char   GifByteType;
  31.  
  32. #define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
  33. #define GIF_EXIT(Msg)   { GIF_MESSAGE(Msg); exit(-3); }
  34.  
  35. #ifdef SYSV
  36. #define VoidPtr char *
  37. #else
  38. #define VoidPtr void *
  39. #endif /* SYSV */
  40.  
  41. typedef struct GifColorType {
  42.     GifByteType Red, Green, Blue;
  43. } GifColorType;
  44.  
  45. /* Note entries prefixed with S are of Screen information, while entries     */
  46. /* prefixed with I are of the current defined Image.                         */
  47. typedef struct GifFileType {
  48.     short SWidth, SHeight,                               /* Screen dimensions. */
  49.         SColorResolution, SBitsPerPixel, /* How many colors can we generate? */
  50.         SBackGroundColor,               /* I hope you understand this one... */
  51.         ILeft, ITop, IWidth, IHeight,           /* Current image dimensions. */
  52.         IInterlace,                          /* Sequential/Interlaced lines. */
  53.         IBitsPerPixel;                    /* How many colors this image has? */
  54.     GifColorType *SColorMap, *IColorMap;              /* NULL if not exists. */
  55.     VoidPtr Private;      /* The regular user should not mess with this one! */
  56. } GifFileType;
  57.  
  58. typedef enum {
  59.     UNDEFINED_RECORD_TYPE,
  60.     SCREEN_DESC_RECORD_TYPE,
  61.     IMAGE_DESC_RECORD_TYPE,                                /* Begin with ',' */
  62.     EXTENSION_RECORD_TYPE,                                 /* Begin with '!' */
  63.     TERMINATE_RECORD_TYPE                                  /* Begin with ';' */
  64. } GifRecordType;
  65.  
  66. /* DumpScreen2Gif routine constants identify type of window/screen to dump.  */
  67. /* Note all values below 1000 are reserved for the IBMPC different display   */
  68. /* devices (it has many!) and are compatible with the numbering TC2.0        */
  69. /* (Turbo C 2.0 compiler for IBM PC) gives to these devices.                 */
  70. typedef enum {
  71.     GIF_DUMP_SGI_WINDOW = 1000,
  72.     GIF_DUMP_X_WINDOW = 1001
  73. } GifScreenDumpType;
  74.  
  75. /******************************************************************************
  76. * O.k. here are the routines one can access in order to encode GIF file:      *
  77. * (GIF_LIB file EGIF_LIB.C).                                                  *
  78. ******************************************************************************/
  79.  
  80. GifFileType *EGifOpenFileName(char *GifFileName, short GifTestExistance);
  81. GifFileType *EGifOpenFileHandle(short GifFileHandle);
  82. void EGifSetGifVersion(char *Version);
  83. short EGifPutScreenDesc(GifFileType *GifFile,
  84.         short GifWidth, short GifHeight, short GifColorRes, short GifBackGround,
  85.         short GifBitsPerPixel, GifColorType *GifColorMap);
  86. short EGifPutImageDesc(GifFileType *GifFile,
  87.         short GifLeft, short GifTop, short Width, short GifHeight, short GifInterlace,
  88.         short GifBitsPerPixel, GifColorType *GifColorMap);
  89. short EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, short GifLineLen);
  90. short EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel);
  91. short EGifPutComment(GifFileType *GifFile, char *GifComment);
  92. short EGifPutExtension(GifFileType *GifFile, short GifExtCode, short GifExtLen,
  93.                                                         VoidPtr GifExtension);
  94. short EGifPutCode(GifFileType *GifFile, short GifCodeSize,
  95.                                                    GifByteType *GifCodeBlock);
  96. short EGifPutCodeNext(GifFileType *GifFile, GifByteType *GifCodeBlock);
  97. short EGifCloseFile(GifFileType *GifFile);
  98.  
  99. #define E_GIF_ERR_OPEN_FAILED   1               /* And EGif possible errors. */
  100. #define E_GIF_ERR_WRITE_FAILED  2
  101. #define E_GIF_ERR_HAS_SCRN_DSCR 3
  102. #define E_GIF_ERR_HAS_IMAG_DSCR 4
  103. #define E_GIF_ERR_NO_COLOR_MAP  5
  104. #define E_GIF_ERR_DATA_TOO_BIG  6
  105. #define E_GIF_ERR_NOT_ENOUGH_MEM 7
  106. #define E_GIF_ERR_DISK_IS_FULL  8
  107. #define E_GIF_ERR_CLOSE_FAILED  9
  108. #define E_GIF_ERR_NOT_WRITEABLE 10
  109.  
  110. /******************************************************************************
  111. * O.k. here are the routines one can access in order to decode GIF file:      *
  112. * (GIF_LIB file DGIF_LIB.C).                                                  *
  113. ******************************************************************************/
  114.  
  115. GifFileType *DGifOpenFileName(char *GifFileName);
  116. GifFileType *DGifOpenFileHandle(short GifFileHandle);
  117. short DGifGetScreenDesc(GifFileType *GifFile);
  118. short DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
  119. short DGifGetImageDesc(GifFileType *GifFile);
  120. short DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, short GifLineLen);
  121. short DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
  122. short DGifGetComment(GifFileType *GifFile, char *GifComment);
  123. short DGifGetExtension(GifFileType *GifFile, short *GifExtCode,
  124.                                                 GifByteType **GifExtension);
  125. short DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
  126. short DGifGetCode(GifFileType *GifFile, short *GifCodeSize,
  127.                                                 GifByteType **GifCodeBlock);
  128. short DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
  129. short DGifGetLZCodes(GifFileType *GifFile, short *GifCode);
  130. short DGifCloseFile(GifFileType *GifFile);
  131.  
  132. #define D_GIF_ERR_OPEN_FAILED   101             /* And DGif possible errors. */
  133. #define D_GIF_ERR_READ_FAILED   102
  134. #define D_GIF_ERR_NOT_GIF_FILE  103
  135. #define D_GIF_ERR_NO_SCRN_DSCR  104
  136. #define D_GIF_ERR_NO_IMAG_DSCR  105
  137. #define D_GIF_ERR_NO_COLOR_MAP  106
  138. #define D_GIF_ERR_WRONG_RECORD  107
  139. #define D_GIF_ERR_DATA_TOO_BIG  108
  140. #define D_GIF_ERR_NOT_ENOUGH_MEM 109
  141. #define D_GIF_ERR_CLOSE_FAILED  110
  142. #define D_GIF_ERR_NOT_READABLE  111
  143. #define D_GIF_ERR_IMAGE_DEFECT  112
  144. #define D_GIF_ERR_EOF_TOO_SOON  113
  145.  
  146. /******************************************************************************
  147. * O.k. here are the routines from GIF_LIB file QUANTIZE.C.                    *
  148. ******************************************************************************/
  149. short QuantizeBuffer(unsigned short Width, unsigned short Height, short *ColorMapSize,
  150.         GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput,
  151.         GifByteType *OutputBuffer, GifColorType *OutputColorMap);
  152.  
  153.  
  154. /******************************************************************************
  155. * O.k. here are the routines from GIF_LIB file QPRINTF.C.                     *
  156. ******************************************************************************/
  157. extern short GifQuitePrint;
  158.  
  159. #ifdef USE_VARARGS
  160. void GifQprintf();
  161. #else
  162. void GifQprintf(char *Format, ...);
  163. #endif /* USE_VARARGS */
  164.  
  165. /******************************************************************************
  166. * O.k. here are the routines from GIF_LIB file GIF_ERR.C.                     *
  167. ******************************************************************************/
  168. void PrintGifError(void);
  169. short GifLastError(void);
  170.  
  171. /******************************************************************************
  172. * O.k. here are the routines from GIF_LIB file DEV2GIF.C.                     *
  173. ******************************************************************************/
  174. short DumpScreen2Gif(char *FileName, short ReqGraphDriver, short ReqGraphMode1,
  175.                                                        short ReqGraphMode2,
  176.                                                        short ReqGraphMode3);
  177. /*   New Commands.... start of sprite handling library */
  178. void sprcpy(unsigned char *dest,unsigned char *src,int size);
  179. void sprcpy2(unsigned char *dest,unsigned char *src,int size);
  180. void sprcpyl(unsigned char *dest,unsigned char *src,int size);
  181. short SaveGif(char *fname,GifByteType *OutputBuffer,
  182.                     GifColorType *OutputColorMap,
  183.                         short ExpColorMapSize, short Width, short Height);
  184. short LoadGif(short Action,char *FileName,
  185.                 GifRowType *ScreenBuffer,GifColorType **ScreenPal,
  186.                 GifFileType *ScreenHeader);
  187.  
  188.  
  189. #endif /* GIF_LIB_H */
  190.